내 응용 프로그램에서 탭 표시 줄 컨트롤러를 사용하고 있습니다.TabBar 응용 프로그램에서 한보기에서 다른보기로 변경할 때 경고를 표시 할 수 없습니까?
탭의 단추를 클릭하여보기를 변경할 수 있지만 탭 단추를 클릭하면 최종 사용자의 확인을 위해 다음과 같은 경고가 표시됩니다. "이 페이지를 떠나야합니다". "예"는 다음 이동하는 경우, 그렇지 않으면 같은 페이지에 유지해야
...
경고하지만, 표시되지 않습니다.
내 응용 프로그램에서 탭 표시 줄 컨트롤러를 사용하고 있습니다.TabBar 응용 프로그램에서 한보기에서 다른보기로 변경할 때 경고를 표시 할 수 없습니까?
탭의 단추를 클릭하여보기를 변경할 수 있지만 탭 단추를 클릭하면 최종 사용자의 확인을 위해 다음과 같은 경고가 표시됩니다. "이 페이지를 떠나야합니다". "예"는 다음 이동하는 경우, 그렇지 않으면 같은 페이지에 유지해야
...
경고하지만, 표시되지 않습니다.
이, UIAlertView의 위임
UIAlertView *myAlert=[[UIAlertView alloc]initWithTitle:@"Alert" message:@"You should leave this page" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil,nil];
[myAlert show];
[myAlert release];
또한
재정의 탭 버튼을 클릭 한 후 호출되는 방법이 전화를 .... 그리고 추가 alertview 코드입니다 메서드
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if(actionSheet==myAlert){
if (buttonIndex == 0)
{
//here call the corresponding page
}
}
else
{
//Do nothing
NSLog(@"cancel");
}
}
보십시오이
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"title" message:@"myMSg" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:@"cancel"];
[alert show];
[alert release];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
//Code for OK button i.e go to the next tab bar
}
if (buttonIndex == 1)
{
//Code for cancel button i.e dont load the next tab bar.
}
}
crea 대신 프로그래밍 방식으로 탭 표시 줄 컨트롤러를 만들 수 있습니다. 팅 각 버튼이 사용 경고보기 후
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// set up a local nav controller which we will reuse for each view controller
UINavigationController *localNavigationController;
// create tab bar controller and array to hold the view controllers
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
// setup the first view controller (Root view controller)
RootViewController *myViewController;
myViewController = [[RootViewController alloc] initWithTabBar];
// create the nav controller and add the root view controller as its first view
localNavigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
// add the new nav controller (with the root view controller inside it)
// to the array of controllers
[localControllersArray addObject:localNavigationController];
// release since we are done with this for now
[localNavigationController release];
[myViewController release];
// setup the first view controller just like the first
ResortsListViewController *resortsListViewController;
resortsListViewController = [[ResortsListViewController alloc] initWithNibName:@"ResortsListView" bundle:nil];
resortsListViewController.title = @"Category1";
resortsListViewController.tabBarItem.image = [UIImage imageNamed:@"image1.png"];
[email protected]"a1";
localNavigationController = [[UINavigationController alloc] initWithRootViewController:resortsListViewController];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
// setup the second view controller just like the first
RootViewController *rootViewController;
rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
rootViewController.title = @"a2";
rootViewController.tabBarItem.image = [UIImage imageNamed:@"image2.png"];
[email protected]"a2";
localNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
// setup the third view controller just like the first
RootViewController *rootViewController;
rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
rootViewController.title = @"a3";
rootViewController.tabBarItem.image = [UIImage imageNamed:@"image3.png"];
[email protected]"ay3";
localNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[rootViewController release];
// load up our tab bar controller with the view controllers
tabBarController.viewControllers = localControllersArray;
// release the array because the tab bar controller now has it
[localControllersArray release];
// add the tabBarController as a subview in the window
[window addSubview:tabBarController.view];
// need this last line to display the window (and tab bar controller)
[window makeKeyAndVisible];
}
& 아래로 XIB 파일 :
UIAlertView *Alert=[[UIAlertView alloc]initWithTitle:@"Alert" message:@"Do you want to leave this page1" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil,nil];
[Alert show];
[Alert release];
[Alert setTag:1];
UIAlertView * 경고 = [[UIAlertView ALLOC] initWithTitle : 경고 "@ "메시지 : @"이 페이지를 떠나시겠습니까? "대리인 : self cancelButtonTitle : @"ok "otherButtonTitles : nil, nil]; [Alert show]; [Alert release]; [경고 세트 태그 : 2]; 으로 누르면 버튼
& 검사 :
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if ([alertView tag] == 1)
if (buttonIndex == 0)
{
//Code for OK button i.e go to the next tab bar
}
if (buttonIndex == 1)
{
//Code for cancel button i.e dont load the next tab bar.
}
}
내가 거기에 5 탭하고 모든 TabBar의에 내가 1 네비게이션 컨트롤러를 추가해야 내가 내 응용 프로그램 view..In 일부 특정 오전에만이 경고를합니다. .. 내가 탭볼을 클릭 할 때마다 경고를하지 않아도됩니다. 제가 몇 가지 중요한 시점에있을 때 ... 감사합니다 !! – Developer
그런 다음 해당 함수에서 어떤 뷰가 호출되는지 확인하고 이에 따라 경고를 표시합니다 .....이 배열과 같은 배열의 모든 컨트롤러를 가져옵니다. [[self tabBarController] viewControllers]; 이 경우 다음을 만족하면 [[array objectAtIndex : 0] sKindOfClass : [YourClassName class]] 푸시 할 컨트롤러가 있는지 확인하십시오. – Minakshi