Tuesday, December 10, 2013

UITabBarController use

The code.
blueViewController = [[BlueViewController alloc] init];
yellowViewController = [[YellowViewController alloc] init];
NSMutableArray * viewControllerArray = [NSMutableArray arrayWithCapacity: 3];
[ViewControllerArray addObject: blueViewController];
[ViewControllerArray addObject: yellowViewController];
tabBar.viewControllers = viewControllerArray;
[Self.view addSubview: tabBar.view];
Why do I use NSMutableArray procedures inexplicable quit? And the console did not report any errors.
Replaced NSArray * viewControllerArray = [NSArray arrayWithObjects: blueViewController, yellowViewController, nil]; completely correct.
NSMutableArray not NSArray subclass it? From the perspective of object-oriented inheritance, there is no question of it! Why is the program aborted? Not an error. .
Reply:
I'll show you examples of it

- (Void) setController
{
NSMutableArray * controllerArray = [[NSMutableArray alloc] init];
UINavigationController * navigationController;
ConfigurationManagement * configurationManagement = [[ConfigurationManagement alloc] init];
navigationController = [self setUINavigationController: configurationManagement
withTag: 0
withImageName: @ "setting.png"
withTabBarTitle: ConfigurationManagementString];
[ControllerArray addObject: navigationController];
[NavigationController release];

Conferencing * conferencing = [[Conferencing alloc] init];
navigationController = [self setUINavigationController: conferencing
withTag: 1
withImageName: @ "meeting.png"
withTabBarTitle: MultMeetingString];
[ControllerArray addObject: navigationController];
[NavigationController release];

ProvisionalMeeting * provisionalMeeting = [[ProvisionalMeeting alloc] initWithNibName: @ "ProvisionalMeeting" bundle: nil];
navigationController = [self setUINavigationController: provisionalMeeting
withTag: 2
withImageName: @ "tmpcall.png"
withTabBarTitle: ProvisionalMeetingString];
[ControllerArray addObject: navigationController];
[NavigationController release];

CallRecords * callRecord = [[CallRecords alloc] init];
navigationController = [self setUINavigationController: callRecord
withTag: 3
withImageName: @ "callhistory.png"
withTabBarTitle: CallRecordsString];
[ControllerArray addObject: navigationController];
[NavigationController release];

tabBarController = [[UITabBarController alloc] init];
[TabBarController setViewControllers: controllerArray animated: NO];
[Window addSubview: tabBarController.view];

[ConfigurationManagement release];
[Conferencing release];
[ProvisionalMeeting release];
[CallRecord release];
[ControllerArray release];

}
Reply:
You have to remember that, alloc thing, be sure to release,
You [self.view addSubview: tabBar.view]; behind the release of all the other call on release,
Your way is the object-oriented theory is wrong, because the object must be recycled, and java, C # automatic recovery you can leave, but Objective - c is not the automatic recovery mechanism,
Reply:
Thank floor reply, but I do not want to get stereotyped answer is copy and paste, which I have no role.
Reply:
reference to the second floor shulianyong reply:
you have to remember that, alloc thing, be sure to release,
You [self.view addSubview: tabBar.view]; behind the release of all the other call on release,
Your way is the object-oriented theory is wrong, because the object must be recycled, and java, C # automatic recovery you can leave, but Objective - c is not the automatic recovery mechanisms,


This is not the memory recovery problems, "Your way is object-oriented theory is wrong, because the object must be recycled," I ask you where book to see? ? I wonder, you know do not know what object-oriented ah? ? It's just an idea, and there are not recycled back to fart object relations ah. Read it for yourself to think in c + +.
Reply:
Okay
LZ mentioningc + + is possible, why not object c, seeking answers

No comments:

Post a Comment