专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Iphone

关于多标签视图的有关问题

发布时间:2010-05-30 01:23:53 文章来源:www.iduyao.cn 采编人员:星星草
关于多标签视图的问题
界面如下图



当我点击第二个标签 single的时候,界面就直接跳出来了,直接调到模拟器的主界面了,怎么回事?



那个标签页的.h代码:如下

C/C++ code

#import <UIKit/UIKit.h>


@interface SingleComponentPickerViewController : UIViewController
<UIPickerViewDelegate,UIPickerViewDataSource>
{
    IBOutlet UIPickerView  *singlepicker;
    NSArray *pickerdate;
    

}
@property (nonatomic,retain) UIPickerView *singlepicker;
@property (nonatomic,retain) NSArray *pickerdate;

-(IBAction)buttonpressed;

@end







标签页 .m 代码

C/C++ code

#import "SingleComponentPickerViewController.h"


@implementation SingleComponentPickerViewController
@synthesize singlepicker;
@synthesize  pickerdate;

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

-(IBAction)buttonpressed
{
    NSInteger row=[singlepicker selectedRowInComponent:0];//select the frist singlepicker
    NSString *select=[pickerdate objectAtIndex:row];
    NSString *title=[[NSString alloc]initWithFormat:@"you select %@",select];
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title
                                                message:@"thanks you for choosing"
                                                delegate:nil
                                       cancelButtonTitle:@"you are welcome" 
                                       otherButtonTitles:nil];
    [alert show];
    [alert release];
    [title release];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    NSArray *array=[[NSArray alloc] initWithObjects:@"Luke",@"Leia",@"Han",@"Chewbacca",@"Artoo",@"Threepio",@"Lando",nil];
    self.pickerdate=array;
    [array release];
    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (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.
}

- (void)viewDidUnload {
    
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [singlepicker release];
    [pickerdate release];
    [super dealloc];
}

#pragma mark -
#pragma mark Picker Data Source Methods
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

-(NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowInComponent:(NSInteger)component
{
    return [pickerdate count];
}
#pragma mark Picker delegate Methods
-(NSString*) pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [pickerdate objectAtIndex:row];
}

@end






------解决方案--------------------
不知道你在IB中怎么链接的~
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: