我正在一個小應用程序,根據要求應用程序應該有一個tabBarItem與3項。爲此,我以編程方式在AppDelegate.m文件中創建了tabBarController,並添加了3個不同的viewController,對它們進行了實例化,並且一切都很好。我看到tabBarItems和所有視圖正在工作。在其中一個視圖讓我們說在SecondViewController中,我顯示了一個popOverController,其中我使用了一個UITableView並用項目填充它。當我點擊其中一個項目時,它應該顯示另一個視圖讓我們說sendFeedback。直到那裏一切工作正常,但只要此sendFeedback呈現爲模式視圖,它佔據了整個應用程序,即隱藏tabBarItem。UITabBarController與UIPopOverController與多個視圖
我在這裏介紹的代碼的重要棋子審查:
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
viewController1.title = @"First";
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
viewController2.title = @"Second";
UITableViewController *tableView3 = [[tableViewController alloc]initWithNibName:@"tableViewController" bundle:nil];
tableView3.title = @"Third";
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, tableView3 ,nil];
self.tabBarController.delegate = self;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
[viewController1 release];
[viewController2 release];
[tableView3 release];
return YES;
}
在我檢查該行表中根據所選擇我popOverViewController.m文件我目前的觀點
#pragma mark - TableView Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
sendFeedback *sendEmailViewController = [[sendFeedback alloc]initWithNibName:@"sendFeedback" bundle:nil];
downLoad *downloadFilelViewController = [[downLoad alloc]initWithNibName:@"downLoad" bundle:nil];
if (indexPath.row == 0)
[self presentModalViewController:sendEmailViewController animated:YES];
else
[self presentModalViewController:downloadFilelViewController animated:YES];
}
任何人都可以指導我如何克服這與多個意見。如果有人需要我的更多信息,我會很樂意提供。
注:這是與其他視圖(下載)以及
編輯同:這裏是我如何初始化我PopOverController在AppDelegate.m文件
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if([viewController isKindOfClass:[SecondViewController class]]){
NSInteger index = [[self tabBarController] selectedIndex];
CGRect buttonFrame = [[[[[self tabBarController] tabBar] subviews] objectAtIndex:index+1] frame];
PopOverViewController *popoverView = [PopOverViewController new];
popoverView.contentSizeForViewInPopover = CGSizeMake(250, 85);
popover = [[UIPopoverController alloc]initWithContentViewController:popoverView];
NSLog(@"X:%f Y:%f",buttonFrame.origin.x,buttonFrame.origin.y);
[popover presentPopoverFromRect:buttonFrame inView:self.tabBarController.tabBar permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
感謝
嗨,多米尼克感謝指出。是否有任何使用此導航堆棧的示例,正如我所說的,我剛開始使用ios的東西。所以,如果有一些例子,將有助於一個例子。 – 125369 2012-02-07 10:00:54
我強烈建議你閱讀[蘋果視圖控制器編程指南](https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html)。這對iOS開發非常重要,所以請花時間仔細閱讀它 - 這是值得的。 – Dominik 2012-02-07 10:10:50
嗨,多米尼克,多數民衆贊成你給一小段代碼,但我得到一個SIGABRT錯誤,當我點擊應顯示PopOverControl的TabBarItem。您能否推薦適合我的代碼的必要更改。謝謝 – 125369 2012-02-07 12:12:19