2013-10-28 3 views
-2

내 응용 프로그램에서 UICOllectionView를 사용했지만 IOS 6.0에서 작동했지만 IOS7에서 실행하려고하면 콜렉션보기가 표시되지 않습니다. i saw this question 나는 주어진 답변을 시도했지만 그만했습니다. dint work, 그리고 나서 콜렉션 뷰의 moveItemAtIndexPath 메소드를 사용하고 셀을 앞뒤로 바꾼 다음 셀이 표시되지만 셀을 아래로 스크롤하면 사라집니다. 내가 사용하는 코드는 hereiOS 7에서 UI 컬렉션보기가 표시되지 않음

+0

온 어떤 문제가 있다면 알려주세요 ... – BalaChandra

+1

당신이 관련 부품을 포함하도록 질문을 수정시겠습니까 당신의 암호? 링크 된 자원은 6 일 후에 만료되고 귀하의 질문은 아직 덜 미래의 방문자를 위해 이해할 수있게됩니다. –

+0

@AlexanderKosubek 나는 연결된 자원을 변경했습니다. – BalaChandra

답변

3

코드를 공부합니다. & 변경합니다.

이 코드를 사용해보십시오. Code

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
     // Do any additional setup after loading the view, typically from a nib. 
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init]; 
    _collectionView=[[UICollectionView alloc] initWithFrame:CGRectMake(130, 100, 780, 1024) collectionViewLayout:layout]; 
    _collectionView.autoresizesSubviews= YES; 
    [_collectionView setDataSource:self]; 
    [_collectionView setDelegate:self]; 
    _collectionView.backgroundColor = [UIColor clearColor]; 

    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"]; 

    [self.view addSubview:_collectionView]; 

} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 
{ 
    return 12; 
} 
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 
{ 
    return 1; 
} 
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; 
    UIView *headertitle = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 375, 20)]; 
    UILabel *titlelabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)]; 
    titlelabel.text = [NSString stringWithFormat:@"graphtitle%d",indexPath.row]; 
    titlelabel.textColor = [UIColor blackColor]; 
    titlelabel.font = [UIFont fontWithName:@"Knewave" size:15.0f]; 
    titlelabel.backgroundColor = [UIColor clearColor]; 
    [headertitle addSubview:titlelabel]; 
    headertitle.backgroundColor = [UIColor whiteColor]; 
    UIWebView *web = [[ UIWebView alloc]initWithFrame:CGRectMake(0, 20, 375, 150)]; 
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]; 
    NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile]; 
    web.scalesPageToFit = YES; 
    [web loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@""]]; 
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom]; 
    button1.backgroundColor = [UIColor clearColor]; 
    button1.frame = CGRectMake(320, 3, 50, 17); 
    [button1 setTitle:@"view" forState:UIControlStateNormal]; 

    [headertitle addSubview:button1]; 
    headertitle.backgroundColor = [UIColor grayColor]; 

    [cell addSubview:headertitle]; 
    [cell addSubview:web]; 

    cell.layer.shadowColor = [[UIColor blackColor]CGColor]; 
    cell.layer.shadowOffset = CGSizeMake(20, 20); 
    cell.layer.borderColor = [[UIColor blackColor] CGColor]; 
    cell.layer.borderWidth =1; 
    //cell.alpha = 1.0f; //Changed here 
    return cell; 
} 

당신은 내가 스토리 보드하지만 같은 문제를 사용하여 시도

+0

이 정보가 도움이 되었습니까? – user1673099

+0

http://stackoverflow.com/help/how-to-answer를 보시기 바랍니다 : 외부 리소스에 대한 링크가 권장됩니다.하지만 링크 주위에 컨텍스트를 추가하여 동료 사용자가 그것이 무엇이며 왜 그것이 무엇인지 알 수 있도록하십시오. 그곳에. 대상 사이트에 도달 할 수 없거나 영구적으로 오프라인 상태가되는 경우 중요한 링크의 가장 중요한 부분을 항상 인용하십시오. –

+0

@ MartinR 귀하의 설명에 감사드립니다. 그래서, 여기에 전체 코드를 쓸 수 있습니까? – user1673099

관련 문제