UIScrollView is probably the only possibility. Divide your document into parts and place into UIScrollView appropriate subViews of classes UITextView, UIImageView and UITableView. To lower memory impact, leave placed only those subViews that are actually visible.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self removeSubViews];
[self addSubViews];
}
- (void)removeSubViews {
for (UIView *subView in documentScrollView.subviews) {
[subView removeFromSuperview];
}
}
- (void)addSubViews {
NSArray* visibleSubViews = [self getAllSubViewsThatAreVisible];
for (UIView *subView in visibleSubViews) {
[documentScrollView addSubview:subView];
}
}
- (NSArray*)getAllSubViewsThatAreVisible {
NSMutableArray* arrayOfSubViews = [[NSMutableArray alloc] init];
NSArray* arrayOfVisibleComponents = [self getAllVisibleComponents];
for (NSDictionary *component in arrayOfVisibleComponents) {
//there you have to create new UITableView, UITextView, or UIImageView according to what is needed and put this new component into arrayOfSubViews
}
return arrayOfSubViews;
}
- (NSArray*)getAllVisibleComponents {
//this is hard to tell how it should be written as I do not know your data. Lets assume, that you have an array of NSDictionary objects. Check all objects in this array, whether they can be visible or not. You shall know their future coordinates in scrollView, while in scrollView, you get visible part by usig property named contentOffset, which will give you top left corner coordinate and by using also property frame.size, you get whole visible rectangle
}
After doing this and testing it, you can optimize it by not removing all subViews and leaving there those that are still visible. Second optimization would be dividing array of compoents according to Y coordinate, so you will not have to iterate whole huge array always. Third optimization can be, that you will not redraw after every small scroll, but will place even some components that are not actually visible, but are close to visible area and after scroll first check whether there is redrawing needed.
XML
parser. I don't have any problem on parsing. I am usingNSXMLParser
. The problem is rendering in a view. – Fultz