pro*_*sam 7 uiview uialertview sigabrt ios
我正在尝试做一个应用程序,你按下按钮然后UIAlertView出现,里面有一个UIView3自定义按钮.到目前为止一切正常.当我点击其中一个按钮时,我想要更改一个图像UIImageView并且也可以.问题在于,每当我尝试启动应用程序时,就会出现sigabrt.
将SIGABRT在我的发生AppDelegate.m在这条线:
self.window.rootViewController = self.viewController;
Run Code Online (Sandbox Code Playgroud)
如果有人可以帮助我那将是伟大的,顺便说一句,我不习惯xcode和objective-c所以我不知道为什么会发生这种情况.
这是我的viewController.h
#import UIKit/UIKit.h (i removed < > cause they were hiding everything inbetween in the post.)
@interface savingstatusViewController : UIViewController {
UIView *loginView;
UIImageView *statusImage;
UIAlertView * MyTicketAlert;
}
- (IBAction)status:(id)sender;
@property (nonatomic, retain) IBOutlet UIView *loginView;
@property (nonatomic, retain) IBOutlet UIImageView *statusImage;
@property (nonatomic, retain) IBOutlet UIAlertView * MyTicketAlert;
- (IBAction)green:(id)sender;
- (IBAction)yellow:(id)sender;
- (IBAction)red:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
这是我的viewController.m
#import "savingstatusViewController.h"
@implementation savingstatusViewController
@synthesize loginView;
@synthesize statusImage,MyTicketAlert;
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[self setLoginView:nil];
[self setStatusImage:nil];
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
- (IBAction)status:(id)sender
{
MyTicketAlert = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:self cancelButtonTitle:nil
otherButtonTitles: nil];
[MyTicketAlert addSubview:loginView];
[MyTicketAlert show];
MyTicketAlert.frame = CGRectMake(0, 1000, 440, 110);
}
- (IBAction)green:(id)sender
{
statusImage.image = [UIImage imageNamed:@"etat_controle.png"];
[MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES];
}
- (IBAction)yellow:(id)sender
{
statusImage.image = [UIImage imageNamed:@"etat_attention.png"];
[MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES];
}
- (IBAction)red:(id)sender
{
statusImage.image = [UIImage imageNamed:@"etat_danger.png"];
[MyTicketAlert dismissWithClickedButtonIndex:0 animated:YES];
}
@end
Run Code Online (Sandbox Code Playgroud)
在iOS4之前,UIWindow rootViewController属性不存在.如果您尝试在iOS 3或更早版本的设备上运行此代码,则会崩溃.
在AppDelegate中,您可以使用addSubview.
//self.window.rootViewController = self.viewController; // Only iOS >= 4
[self.window addSubview:self.viewController.view];
[self.window makeKeyAndVisible];
return YES;
Run Code Online (Sandbox Code Playgroud)
小智 2
转到 MainWindow.xib 中的“TheNameOfYourProjetdelegate”。
在“TheNameOfYourProjetdelegate”的“outlet”中,您必须有viewController,然后“控制拖动”到您的窗口并运行您的应用程序
| 归档时间: |
|
| 查看次数: |
9880 次 |
| 最近记录: |