我有一个带有2个CollectionView控制器的viewcontroller.
我想轮换时只有一个集合视图调整为自定义大小而另一个保持不变.
我试过用:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
// Adjust cell size for orientation
if (UIDeviceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
return CGSizeMake(170.f, 170.f);
}
return CGSizeMake(192.f, 192.f);
}
Run Code Online (Sandbox Code Playgroud)
但是,这只会改变两个集合视图.如何让它仅针对一个集合?
最终结果是在一个视图控制器上有2个集合视图.从不同的来源拉动以及一个应该水平滚动而另一个垂直滚动.
请告知如何以编程方式实现此目的.
我使用集合视图开发了一个RSS阅读器应用程序.我的问题是,在第一次启动时,应用程序出现空白.
过程是,RSS提要从Web中提取,存储到设备上的临时文件中,然后通过集合视图显示.
我的问题是如何在文件加载后让应用程序自动重新加载数据?这样用户就看不到初始的空白屏幕.
我试过添加这段代码
[self.collection1 performBatchUpdates:^{
[self.collection1 reloadSections:[NSIndexSet indexSetWithIndex:0]];
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
但是它不适用于初始视图.
我应该从appdelegate做些什么吗?或者从集合视图控制器本身?
请指教
下面是用于获取和显示我的数据的代码....
#pragma mark - UICollectionViewDataSourceDelegate
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [_articleListmain count];
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
MainCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"articleCellmain"
forIndexPath:indexPath];
NSDictionary *item = [_articleListmain objectAtIndex:indexPath.item];
// set the article image
[cell.image setImageWithURL:[item objectForKey:@"image"]];
// set the text of title UILabel
cell.title.text = [NSString stringWithFormat:@"%@\n\n\n\n", [item objectForKey:@"title"]];
cell.title.textColor = [UIColor …Run Code Online (Sandbox Code Playgroud) 我试图使用CSS和HTML的组合重新创建此图像,没有运气.请指教.
现行代码:
.lens-profile-timeline {
list-style: none;
padding: 0;
margin: 60px 0 80px;
border-bottom: 8px solid #39752c;
position: relative;
}
.lens-profile-timeline li {
position: absolute;
width: 16px;
height: 16px;
border: 13px solid #39752c;
border-radius: 16px;
background: #fff;
margin-top: -10px;
margin-left: 20px;
margin-right: 20px;
}
.lens-profile-timeline time,
.lens-profile-timeline p {
left: -27px;
top: -40px;
position: absolute;
width: 70px;
text-align: center;
}
.lens-profile-timeline time {
margin-top: 70px;
font-size: 18px;
}
.lens-profile-timeline p {
margin-top: -0px;
font-size: 10px;
line-height: 1.1;
}
.lens-profile-timeline p:after { …Run Code Online (Sandbox Code Playgroud)问题:这个过程与iOS6完美配合.现在它不会提取最新信息并替换显示的数据.因此,应用程序信息总是错误的.如果我重置模拟器上的内容,它可以在当前时间段内工作.之后我将需要重新设置内容.有什么建议.我已经包含了处理我所有数据处理的3个文件以供参考.
Reader.M
- (void) startRequest
{
NSURL *url = [[NSURL alloc] initWithString:@"http://www.something.com/app/rss/"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:60.0f];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self startImmediately:YES];
if(conn)
{
_receivedData = [[NSMutableData alloc]init];
}
}
#pragma mark - NSURLConnectionDataDelegate
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"%@",error.description);
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"received %d bytes",data.length);
[_receivedData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:_receivedData];
JSTRRSSParser *rssParser = [[JSTRRSSParser alloc] init];
parser.delegate = rssParser; …Run Code Online (Sandbox Code Playgroud) ios ×4
css ×1
css-shapes ×1
html ×1
nsdictionary ×1
nsxmlparser ×1
objective-c ×1
reloaddata ×1
xcode ×1