嗨,我有一个问题,当我单击按钮时,我无法通过按钮将值从一个视图控制器传递到另一个视图控制器,其他视图出现在 iphone 屏幕上,但我设置的值不显示这是按钮代码
-(IBAction)save:(id)sender
{
nextview *admin = [[nextview alloc]init];
[self presentModalViewController:admin animated:YES];
if (admin.view)
{
admin.fetchname = name.text;
}
[admin release];
}
这是 nextview.h 文件
#import <UIKit/UIKit.h>
@interface nextview : UIViewController
{
UILabel *getname;
NSString *fetchname;
}
@property (nonatomic,retain) IBOutlet NSString *fetchname;
@property (nonatomic,retain) IBOutlet UILabel *getname;
@end
这是 nextview.m 文件
#import "nextview.h"
#import "ViewController.h"
@implementation nextview
@synthesize getname,fetchname;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (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
{
getname.text = self.fetchname;
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end