开发者

indexPathsForVisibleRows returns the total table size instead of visible after resize

开发者 https://www.devze.com 2023-03-28 12:05 出处:网络
I am building a chat app, its going all good until i sta开发者_Python百科rted implementing the auto scroll for UITableView when the keyboard shows up/down.

I am building a chat app, its going all good until i sta开发者_Python百科rted implementing the auto scroll for UITableView when the keyboard shows up/down.

The indexPathsForVisibleRows's resulting NSArray size was increasing after scrolls even if the height of every row/cell is constant. I searched on here and found out that there was a bug. According to the suggestions, i added the below line:

[table visibleCells];

before using indexPathsForVisibleRows:

scrollPosition = (NSIndexPath*)[[table indexPathsForVisibleRows] objectAtIndex:0];

in:

- (void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView;

This fixed the issue when the keyboard was hidden and the table was fullsized (not resized).

When the user taps on the textField, the keyboard shows up and the UITableView's height gets decreased by the amount of the keyboard's height.

At this point when a scroll happens, the get around of using

[table visibleCells];

does not work and the resulting size of the indexPathsForVisibleRows NSArray becomes the total rows of the table instead of just the visible ones.

Is this another Bug or am i doing something wrong?

0

精彩评论

暂无评论...
验证码 换一张
取 消