0
A
回答
3
我已经创建了一个搜索栏并添加了文本框作为它的子视图。
UIAlertView * myAlertView = [[UIAlertView alloc] initWithTitle:@" "
message:@" "
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil, nil];
UISearchBar *myTextField = [[UISearchBar alloc] initWithFrame:CGRectMake(30.0, 35.0, 180.0, 35.0)];
UIButton *searchbtn = [[UIButton alloc] initWithFrame:CGRectMake(230.0, 35.0, 40.0, 35.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView setBackgroundColor:[UIColor grayColor]];
[searchbtn setBackgroundColor:[UIColor grayColor]];
[myAlertView addSubview:myTextField];
[myAlertView addSubview:searchbtn];
如果还有其他更好的方法,请让我知道。
1
有一个更好的办法:
UIAlertView *myAlertView = [[[UIAlertView alloc] initWithTitle:@"Keyword Search"
message:@""
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Search", nil] autorelease];
myAlertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[myAlertView show];
而在代表:
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSString *searchTerm = [alertView textFieldAtIndex:0].text;
}
相关问题
- 1. 创建一个阶梯式搜索栏
- 2. 创建搜索栏
- 3. 如何创建一个像iphone一样的搜索android
- 4. 如何创建一个搜索栏输入搜索表中的每一列使用php
- 5. 建立一个搜索栏
- 6. 在ios 5中创建一个统一的地址搜索栏?
- 7. 如何创建一个实时搜索栏?
- 8. 如何在iPhone应用程序中创建类似Spotlight的搜索栏?
- 9. 如何使用笔尖创建伪alertview?
- 10. 如何在iPhone中实现搜索栏?
- 11. 如何在导航栏下添加搜索栏并通过点击搜索栏创建一个动作表
- 12. 创建一个用url_for()插入URI变量的Flask搜索栏
- 13. 如何在swift中创建两个搜索栏?
- 14. 如何创建搜索栏来更新搜索输入
- 15. 如何在天气应用程序中创建一个搜索栏?
- 16. 在列表视图中创建一个搜索栏
- 17. 如何创建一个搜索,搜索引擎友好(mod_rewrite htaccess)
- 18. 如何在iPhone的导航栏中添加搜索栏
- 19. 如何停止使用iPhone的tableheader滚动搜索栏
- 20. 如何创建像JqGrid中的ExtJS Grid工具栏搜索
- 21. 如何禁用iPhone中的alertview按钮?
- 22. Django,创建一个功能性搜索栏和搜索结果页面
- 23. 如何在iphone导航栏中添加搜索栏?
- 24. 如何使用另一个AlertView显示AlertView
- 25. 如何将一个搜索栏放入(不在)导航栏中?
- 26. 如何在上下文操作栏中创建“搜索”字段?
- 27. 如何添加一个搜索栏搜索
- 28. 为十六进制值创建一个搜索栏
- 29. iPhone搜索栏设计
- 30. 如何隐藏或删除iPhone中的UiWebView中的搜索栏