Tôi đã triển khai UICollectionView
trong ứng dụng của mình. Vấn đề của tôi là tôi cần phải chọn (như nếu người dùng gõ vào nó) một ô programmatically
. Phương pháp:Cách chọn mục/ô của UICollectionView từ mã
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath
animated:(BOOL)animated
scrollPosition:(UICollectionViewScrollPosition)scrollPosition
Đó là một phần của lớp UICollectionView
không phải là những gì tôi cần phải gọi, vì phương pháp này không gọi:
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
Nó chỉ đặt selected
tài sản của các tế bào để YES
;
Còn việc tự gọi phương thức sau khi bạn đã chọn ô của mình thì sao? Bạn có thể gọi [self collectionView: yourView didSelectItemAtIndexPath: yourIndexPath]; –
Có. hiểu rồi. cảm ơn! –
Có lẽ câu trả lời này sẽ giúp bạn http://stackoverflow.com/questions/13177201/select-items-programmatically-in-uicollectionview –