WEB开发网
开发学院手机开发iPhone 开发 在iPhone开发中给键盘加个隐藏工具条 阅读

在iPhone开发中给键盘加个隐藏工具条

 2010-12-18 08:06:24 来源:WEB开发网   
核心提示: Created by walkman on 10-12-2.// Copyright 2010 手机主题下载 http://www.shouji138.com All rights reserved.//#import "KeyBoardTopBar.h"@implementation KeyBo

//

// Created by walkman on 10-12-2.

// Copyright 2010 手机主题下载 http://www.shouji138.com All rights reserved.

//

#import "KeyBoardTopBar.h"

@implementation KeyBoardTopBar

@synthesize view;

//初始化控件和变量

-(id)init{

if(self = [super init]) {

prevButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"上一项" style:UIBarButtonItemStyleBordered target:self action:@selector(ShowPrevious)];

nextButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"下一项" style:UIBarButtonItemStyleBordered target:self action:@selector(ShowNext)];

hiddenButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"隐藏键盘" style:UIBarButtonItemStyleBordered target:self action:@selector(HiddenKeyBoard)];

spaceButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

view = [[UIToolbar alloc] initWithFrame:CGRectMake(0,480,320,44)];

view.barStyle = UIBarStyleBlackTranslucent;

view.items = [NSArray arrayWithObjects:prevButtonItem,nextButtonItem,spaceButtonItem,hiddenButtonItem,nil];

allowShowPreAndNext = YES;

TextFields = nil;

isInNavigationController = YES;

currentTextField = nil;

}

return self;

}

//设置是否在导航视图中

-(void)setIsInNavigationController:(BOOL)isbool{

isInNavigationController = isbool;

}

//显示上一项

-(void)ShowPrevious{

if (TextFields==nil) {

return;

}

NSInteger num = -1;

for (NSInteger i=0; i<[TextFields count]; i++) {

if ([TextFields objectAtIndex:i]==currentTextField) {

num = i;

break;

}

}

if (num>0){

[[TextFields objectAtIndex:num] resignFirstResponder];

上一页  1 2 3 4 5  下一页

Tags:iPhone 开发 键盘

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接