/***********************************************************************************/
#import "AppDelegate.h"
#import "LTView.h"
@interface AppDelegate ()<UIAlertViewDelegate>
@end
@implementation AppDelegate
-(void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window =[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor =[UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
UIViewController *vc=[[UIViewController alloc]init];
self.window.rootViewController =vc;
[vc release];
LTView *view = [[LTView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width,80 )];
view.backgroundColor =[UIColor yellowColor];
[self.window addSubview:view];
[view release];
view.label.text =@"姓名";
view.textField.placeholder =@"请输入姓名";
UIImageView *image =[[UIImageView alloc] initWithFrame:CGRectMake(80, 80, 200, 200)];
image.backgroundColor =[UIColor redColor];
[self.window addSubview:image];
[image release];
image.image =[UIImage imageNamed:@"/Users/dllo/Desktop/UI03_LTView/UI03_LTView/asdasd.jpg"];
// UIImageView *image =[[UIImageView alloc] initWithFrame:CGRectMake(80, 80, 200, 200)];
// image.backgroundColor =[UIColor redColor];
// [self.window addSubview:image];
// [image release];
// image.image =[UIImage imageNamed:@"/Users/dllo/Desktop/UI03_LTView/UI03_LTView/asdasd.jpg"];
///UIAlertView
// UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"程锦乐" message:@"真的吗" delegate:self cancelButtonTitle:@"真的" otherButtonTitles:@"假的", nil];
UIActionSheet
给提示窗口加入输入框
// alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
// [alert show];
return YES;
}
**** UIAlertView的方法 用的时候需要签协议
//-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
//{
// NSLog(@"%ld",buttonIndex);
// ///获取输入内容
// UITextField *text =[alertView textFieldAtIndex:0];
// NSLog(@"%@",text.text);
//}
@interface LTView : UIView<UITextFieldDelegate>
@property(nonatomic,retain)UILabel *label;
@property(nonatomic,retain)UITextField *textField;
@end
//
#import "LTView.h"
@implementation LTView
//为了创建一个LTView就可以同时把两个视图都创建出来,所以重写初始化方法
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
//创建两个视图
[self createView];
}
return self;
}
-(void)createView
{
self.label =[[UILabel alloc]initWithFrame:CGRectMake(20,20,150,50 )];
self.label.layer.borderWidth =1;
self.label.layer.cornerRadius =25;
self.label.layer.masksToBounds =YES;
self.label.textAlignment =1;
[self addSubview: self.label];
[_label release];
self.textField =[[UITextField alloc]initWithFrame:CGRectMake(180, 20, 150, 50)];
self.textField.layer.borderWidth =1;
self.textField.layer.cornerRadius=25;
self.textField.clearButtonMode =UITextFieldViewModeAlways;
[self addSubview:self.textField];
[_textField release];
self.textField.delegate =self;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.textField resignFirstResponder];
return YES;
}
-(void)dealloc
{
[_label release];
[_textField release];
[super dealloc];
}
@end