小编ole*_*egi的帖子

滚动UITableView时隐藏键盘

在我的应用程序中,当我开始滚动UITableView时,我想隐藏键盘.我在互联网上搜索这个,大多数答案是子类化UITableView(http://stackoverflow.com/questions/3499810/tapping-a-uiscrollview-to-hide-the-keyboard).

我做了子类但它不起作用.

#import <UIKit/UIKit.h>

@protocol MyUITableViewDelegate <NSObject>
@optional
- (void)myUITableViewTouchesBegan;
@end

@interface MyUITableView : UITableView <UITableViewDelegate, UIScrollViewDelegate> {
    id<MyUITableViewDelegate> delegate;
}
@end
Run Code Online (Sandbox Code Playgroud)

.m文件

#import "MyUITableView.h"

@implementation MyUITableView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    NSLog(@"delegate scrollView"); //this is dont'work
    [super scrollViewDidScroll:scrollView];
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"delegate myUITableViewTouchesBegan"); // work only here
    [delegate myUITableViewTouchesBegan];
    [super touchesBegan:touches withEvent:event];

}

- (void)dealloc {
...
Run Code Online (Sandbox Code Playgroud)

我像这样使用这个类.但委托函数myUITableViewTouchesBegan在ViewController中不起作用

.H

#import <UIKit/UIKit.h>
#import "MyUITableView.h"

@interface FirstViewController : UIViewController <UITableViewDelegate, UISearchBarDelegate, MyUITableViewDelegate> {
    MyUITableView *myTableView;
    UISearchBar *searchBar; 
}

@property(nonatomic,retain) …
Run Code Online (Sandbox Code Playgroud)

keyboard scroll uitableview ios

124
推荐指数
5
解决办法
6万
查看次数

android listview项目高度

为什么当我使用SimpleCursorAdapter for ListView时,我在ListView中有像这样的项高度 - 列表视图图像

(我的代码基于)

但是当使用数组Listview项目有很大的高度

listview大

(我基于学习listview )

项目列表视图的行布局是

<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)

所以我的问题是为什么使用ArrayAdapter和SimpleCursorAdapter时行高的差异?

android listview row android-arrayadapter simplecursoradapter

51
推荐指数
4
解决办法
12万
查看次数