久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在情節(jié)提要中的 UIViewControllers 之間手動切換

How can I manually switch between UIViewControllers in storyboard?(如何在情節(jié)提要中的 UIViewControllers 之間手動切換?)
本文介紹了如何在情節(jié)提要中的 UIViewControllers 之間手動切換?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我只需要使用代碼手動查看同一故事板文件中的 UIView 控制器.我使用故事板來制作所有形式和連接.我的應(yīng)用程序從導(dǎo)航控制器開始,它讓我可以訪問 UIView (LoginViewController),然后它進入標(biāo)簽欄控制器,它提供 4 個 UIViews.根據(jù)每個 UIView 我有 .h.m 文件.我知道segue方法,它很簡單,但我需要手動方法.也許我做錯了什么.

All I need is to view a UIView controller in same storyboard file manually with code. I use storyboard to make all forms and connections. My application starts in navigation controller, which provides me access to UIView (LoginViewController) and then it goes to tab bar controller, which provides 4 UIViews. According to every UIView I have .h and .m files. I know about segue method, it is simple, but I need manual method. Maybe I am doing something wrong.

我試圖在 IBAction 中使用這種方法推送視圖控制器:

I was trying to use this method for pushing view controller in IBAction:

[self.view pushViewController:LoginViewController animated:YES];

但它會出錯:

意外的接口名稱LoginViewController":預(yù)期的表達式

Unexpected interface name ‘LoginViewController’: expected expression

我花了很長時間才弄清楚出了什么問題,但我沒有成功.這是我的 RollEnemyController.m 文件:

It took a lot of time to figure out what is wrong, but I had not succeed. Here is my RollEnemyController.m file:

//  RollEnemyController.m
#import "RollEnemyController.h"
#import "LoginViewController.h"
@implementation RollEnemyController;
@synthesize AttackButtonPressed;

- (IBAction)AttackButtonPressed:(id)sender {
    LoginViewController* controller = [[LoginViewController alloc] initWithNibName:@"LoginViewController"  bundle:nil];
    [self.view pushViewController:controller];
}

@end

這是頭文件:

//  RollEnemyController.h

#import <UIKit/UIKit.h>

@interface RollEnemyController : UIViewController

- (IBAction)RollButtonPressed:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *AttackButtonPressed;

@end

推薦答案

我猜你正在使用 UINavigationController.然后你可以簡單地這樣做:

I'm guessing that you are using a UINavigationController. Then you can simply do like this:

LoginViewController *controller = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];

更新:

如果您使用的是 UIStoryboard,您可以設(shè)置新視圖控制器的標(biāo)識符,然后將其推送到您的導(dǎo)航控制器上.要設(shè)置標(biāo)識符,請選擇您的視圖,打開 Attributes Inspector,然后設(shè)置標(biāo)識符(在我的示例中為LoginIdentifier").然后你可以這樣做:

If you are using a UIStoryboard, you can set the identifier of your new viewcontroller, and then push it onto your navigationController. To set the identifier, choose your view, open the Attributes Inspector, and set the identifier ("LoginIdentifier" in my example). Then you can do this:

LoginViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"LoginIdentifier"];
[self.navigationController pushViewController:controller animated:YES];

作為旁注,我看到您在方法中使用了大寫字符.您可能應(yīng)該盡量避免這種情況,而是在方法名稱中使用降低的首字符.既然你說你正在學(xué)習(xí) Objective-C,你應(yīng)該在這里查看這個很棒的線程:鏈接.

As a sidenote, I see that you are using capital characters for your methods. You should probably try to avoid that, and instead use lowered first-characters in your method names. And since you say you are learning Objective-C, you should check out this awesome thread here on SO: link.

更新 2:

這里是一個 zip 文件,其中包含一個項目,展示了如何執(zhí)行此操作.:-)

Here is a zip file with a project showing how to do this. :-)

這篇關(guān)于如何在情節(jié)提要中的 UIViewControllers 之間手動切換?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應(yīng)用程序源代碼的情況下使用 Instruments 測試 iOS 應(yīng)用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應(yīng)用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標(biāo)成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態(tài)和動態(tài)單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 美女二区 | 日韩有码一区 | 国产精品美女久久久免费 | 国产精品久久久久一区二区三区 | 91视视频在线观看入口直接观看 | 色视频www在线播放国产人成 | 欧美日韩国产精品一区 | 欧美性久久 | 99久久久99久久国产片鸭王 | 欧美日韩高清一区二区三区 | 一级a毛片| 国产九一精品 | 综合久久久 | 亚洲福利一区二区 | 伊人狠狠| 国产精品久久久久久久久久久久久久 | 天堂亚洲| 久久综合伊人 | 国产探花在线精品一区二区 | 欧美激情久久久久久 | 午夜精品久久久 | 福利视频网站 | 成人免费看黄 | 自拍偷拍中文字幕 | 男女啪啪网址 | 成人三级影院 | 精品videossex高潮汇编 | 天天爽天天操 | 国产精品一区二区三区在线播放 | 蜜桃官网| 欧美一级做a爰片免费视频 国产美女特级嫩嫩嫩bbb片 | 超碰在线国产 | 精品99久久 | 日日精品 | 黄色片在线观看网址 | 少妇一级淫片免费播放 | 成av在线 | 午夜精品久久 | 成人二区 | 欧美日韩三区 | 国产精品久久a |