gpt4 book ai didi

ios - 将 iPad 中显示的两个 Controller 分开显示在同一屏幕中以在 iPhone 中使用

转载 作者:行者123 更新时间:2023-11-29 01:16:06 25 4
gpt4 key购买 nike

我正在尝试将 iPad 项目转换为 iPhone 项目。我曾经使用 Android 应用程序,所以这对我来说是一项艰苦的工作。

在 iPad 中,我有一个包含两个容器的屏幕:ContainerProfile 和 ContainerSection。容器配置文件始终显示配置文件,容器部分用于显示您可以在菜单中选择的不同选项,以及排名、社交、奖励等内容......

在 iPhone 中这些容器永远不会同时看到它,因为屏幕较小,所以我可以做些什么来分开它们?如果您需要更多信息,请告诉我。

对不起,因为我没解释好。菜单位于顶部栏中,您可以在右侧容器中看到有关此菜单的信息,但现在在 iPhone 中这是不可能的。我给你代码让你有更多的想法。

#import “ATMyProfileContainerViewController.h"
#import “ATMyProfileMainViewController.h"
#import “ATSocialSectionContainerViewController.h"
#import “ATPortfolioSectionContainerViewController.h"
#import “ATUserRankingSectionContainerViewController.h"
#import “ATPortfolioRankingSectionContainerViewController.h"
#import “ATAchievementSectionContainerViewController.h"
#import “ATConnectionHelper.h"
#import “ATConstants.h"
#import "HelperText.h"
#import “ATAppDelegate.h"
#import “ATPicture.h"
#import "Pictures.h"
#import "Pictures+Create.h"
#import “ATSectionContainerViewController.h"

@interface ATMyProfileContainerViewController()<ATConnectionHelperDelegate>{
ATSectionContainerViewController *_currentSectionController;
ATMyProfileOptions _currentOptionSelected;

}
@property (nonatomic,weak) ATMyProfileMainViewController *myProfileViewController;

@property (weak, nonatomic) IBOutlet UIView *viewContainerProfile;
@property (weak, nonatomic) IBOutlet UIView *viewContainerSection;

@end

@implementation ATMyProfileContainerViewController

- (void)viewDidLoad {
[super viewDidLoad];

// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

-(void)loadUserProfile:(ATPrivateUserProfileModel *)profile{
self.userProfile=profile;
TAMyProfileMainViewController* controller;
if (_myProfileViewController==nil) {
controller= [self.storyboard instantiateViewControllerWithIdentifier:@“ATMyProfileMainViewController"];

}else
{
//controller=_myProfileViewController;
}
[controller setUserProfile:self.userProfile];
[self setProfileInContainer:controller];
// [_myProfileViewController reloadData];

}

- (void)setProfileInContainer:(ATMyProfileMainViewController*)controller{
if (_myProfileViewController) {
[_myProfileViewController.view removeFromSuperview];
[_myProfileViewController removeFromParentViewController];
_myProfileViewController=nil;
}
if (controller!=nil) {
controller.view.frame=self.viewContainerProfile.bounds;
[self addChildViewController:controller];
[self.viewContainerProfile addSubview:controller.view];
[controller didMoveToParentViewController:self];
_myProfileViewController=controller;
}
}

-(void)selectSection:(ATMyProfileOptions)optionSelected{
_currentOptionSelected=optionSelected;

if (optionSelected==Social) {
ATSocialSectionContainerViewController *socialController=[self.storyboard instantiateViewControllerWithIdentifier:@"SocialSectionContainer"];
socialController.userProfile=self.userProfile;
[self replaceSectionControllerWith:socialController];
}
else if (optionSelected==Profiles){
ATMyProfileMainViewController *Controller=[self.storyboard instantiateViewControllerWithIdentifier:@“ATMyProfileMainViewController"];
Controller.userProfile=self.userProfile;
[self replaceSectionControllerWith:Controller];

}
else if (optionSelected==Portfolios){
ATPortfolioSectionContainerViewController *portfolioController=[self.storyboard instantiateViewControllerWithIdentifier:@"PortfolioSectionContainer"];
portfolioController.userProfile=self.userProfile;
portfolioController.portfolioInfoDelegate=self.portfolioInfoDelegate;
[self replaceSectionControllerWith:portfolioController];

}
else if (optionSelected==UserRanking){
ATUserRankingSectionContainerViewController *userRankingController=[self.storyboard instantiateViewControllerWithIdentifier:@"UserRankingSectionContainer"];
userRankingController.userProfile=self.userProfile;
[self replaceSectionControllerWith:userRankingController];

}
else if (optionSelected==PortfolioRanking){
ATPortfolioRankingSectionContainerViewController *portfolioRankingController=[self.storyboard instantiateViewControllerWithIdentifier:@"PortfolioRankingSectionContainer"];
portfolioRankingController.userProfile=self.userProfile;
portfolioRankingController.portfolioInfoDelegate=self.portfolioInfoDelegate;
[self replaceSectionControllerWith:portfolioRankingController];

}
else if (optionSelected==Achivements){
ATAchievementSectionContainerViewController *achievementController=[self.storyboard instantiateViewControllerWithIdentifier:@"AchievementSectionContainer"];
achievementController.userProfile=self.userProfile;
[self replaceSectionControllerWith:achievementController];

}
}

-(void) replaceSectionControllerWith:(ATSectionContainerViewController *)newController{

[UIView transitionWithView:self.viewContainerSection
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^(void){
if (_currentSectionController){
[_currentSectionController.view removeFromSuperview];
[_currentSectionController removeFromParentViewController];
_currentSectionController=nil;
}

if(newController)
{
newController.goPublicProfileDelegate=self.goPublicProfileDelegate;
newController.view.frame=self.viewContainerSection.bounds;
[self addChildViewController:newController];
[self.viewContainerSection addSubview:newController.view];
[newController didMoveToParentViewController:self];
_currentSectionController=newController;
}
}
completion:NULL];

}

#pragma mark -updateUserProfileiPhoneDelegate

-(void)refreshiPUserProfile:(ATPrivateUserProfileModel *)newUserProfile{
[self loadUserProfile:newUserProfile];
[self selectSection:_currentOptionSelected];
}
-(void)reloadUserProfile
{
//TODO: RECARGAR EL PERFIL ENTERO.
[TAConnectionHelper requestToTAdvisorUrl:kUrlPrivateProfileData withParameters:nil delegate:self tag:102];
}

#pragma mark - ATConnectionHelperDelegate

- (void)responseWithData:(NSDictionary*)dataDict tag:(NSInteger)tag{
if(tag ==102)
{
NSDictionary* data=[dataDict objectForKey:@"DATA"];
NSError *error=nil;
ATPrivateUserProfileModel *aux = [MTLJSONAdapter modelOfClass:[ATPrivateUserProfileModel class] fromJSONDictionary:data error:&error];
aux.notificationSummary=self.userProfile.notificationSummary;
[(ATAppDelegate*)[[UIApplication sharedApplication] delegate] setUserPrivateProfile:aux];
[self refreshiPUserProfile:aux];
//[self asyncLoad];
}
}
- (void)responseWitError:(NSError*)error textError:(NSString*)textError dictionaryError:(NSDictionary*)errorDict tag:(NSInteger)tag{
if (tag==102){
UIAlertView* alert=[[UIAlertView alloc] initWithTitle:[TAHelperText getText:@"Alrt_Alert"] message:[TAHelperText getText:@"Alrt_ErrorReg"] delegate:nil cancelButtonTitle:[TAHelperText getText:@"Alrt_Ok"] otherButtonTitles: nil];
[alert show];
}
}

#pragma mark - ATiPNavigationMenuDelegate

- (void)didSelectItemAtIndex:(NSUInteger)index
{
switch (index) {
case 2:
[self selectSection:Social];
break;
case 0:
[self selectSection:Profiles];
break;
case 4:
[self selectSection:Achivements];
break;
case 1:
[self selectSection:Portfolios];
break;
case 5:
[self selectSection:UserRanking];
break;
case 6:
[self selectSection:PortfolioRanking];
break;
default:
[self selectSection:Portfolios];
break;
}


NSLog(@"did selected item at index %lu", (unsigned long)index);
}

@end

我不知道是否可以在同一屏幕上使用相同的容器并在菜单中选择某些内容时隐藏 de containerPerfil 或者什么是最佳解决方案。

谢谢

最佳答案

您可以使用 UISplitViewController。

UISplitViewController 显示屏幕左侧的项目和有关所选项目的右侧信息(仅当您使用横向 iPad 时)。如果您使用的是纵向 iPhone 或 iPad,请首先展示您的元素。如果您选择一个项目,您可以看到详细信息。

关于ios - 将 iPad 中显示的两个 Controller 分开显示在同一屏幕中以在 iPhone 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35159071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com