我正在尝试为我的应用创建一个欢迎页面(带截图)。
我已经采取了一些样本并将其制作成文本卷轴。我已经试了好几个星期而没有任何成功。感谢
int numberOfPages = 5;
UIScrollView *someScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
someScrollView.pagingEnabled = YES;
someScrollView.contentSize = CGSizeMake(numberOfPages * someScrollView.frame.size.width, someScrollView.frame.size.height);
[self.view addSubview:someScrollView];
for (int i = 0; i < numberOfPages; i++) {
UILabel *tmpLabel = [[UILabel alloc] initWithFrame:CGRectMake(i * someScrollView.frame.size.width + 20,
20,
someScrollView.frame.size.width - 40,
20)];
tmpLabel.textAlignment = UITextAlignmentCenter;
tmpLabel.text = [NSString stringWithFormat:@"THIS ACTUALLY WORKS!! %d", i];
[someScrollView addSubview:tmpLabel];
}
这是我尝试处理图片失败的原因:
int numberOfPages = 5;
UIScrollView *someScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
someScrollView.pagingEnabled = YES;
someScrollView.contentSize = CGSizeMake(numberOfPages * someScrollView.frame.size.width, someScrollView.frame.size.height);
[self.view addSubview:someScrollView];
for (int i = 0; i < numberOfPages; i++) {
UIImageView *tmpLabel = [[UIImageView alloc] initWithFrame:CGRectMake(i * someScrollView.frame.size.width + 20,
20,
someScrollView.frame.size.width - 40,
20)];
tmpLabel.imageAlignment = UIImageAlignmentCenter;
tmpLabel.text = [NSString stringWithFormat:@"THIS ACTUALLY WORKS!! %d", i];
[someScrollView addSubview:tmpLabel];
}
UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:subview1.frame];
if (i == 0) {
imageView1.image = [UIImage imageNamed:@"openingScreen1.png"];
}else if (i == 1){
imageView1.image = [UIImage imageNamed:@"openingScreen2.png"];
}else if (i == 2){
imageView1.image = [UIImage imageNamed:@"openingScreen3.png"];
}else {
imageView1.image = [UIImage imageNamed:@"openingScreen4.png"];
}
我也可能需要删除&#34; Parse&#34;除非上面的图像坐在它上面?我找不到这个词。
答案 0 :(得分:1)
试试这个
<AuditData>
<ProcessTime>2128</ProcessTime>
<Timestamp>2014-05-06 11:35:52.042</Timestamp>
<RequestHost>127.0.0.1</RequestHost>
<ServerName>SIS</ServerName>
<ServerId>01</ServerId>
<SchemaRelease>2005/06</SchemaRelease>
<HydraCoreRelease>2.0.201405051526</HydraCoreRelease>
<HydraEnumerationsRelease>1.0.201405051526</HydraEnumerationsRelease>
<MerlinRelease>N/A</MerlinRelease>
</AuditData>
<PaginationData currentPage="1" totalPages="10"/>
<ServiceHotel xsi:type="ServiceHotel" availToken="1T30xpRg+eHNFvzJSa38uwbd">
<DirectPayment>Y</DirectPayment>
<ContractList>
<Contract>
<Name>NRF-TODOS1~</Name>
<IncomingOffice code="1"/>
<Classification code="NRF">Non refundable rate</Classification>
</Contract>
</ContractList>
<DateFrom date="20140706"/>
<DateTo date="20140708"/>
<Currency code="EUR">Euro</Currency>
<PackageRate>N</PackageRate>
<TravelAgent>N</TravelAgent>
<HotelInfo xsi:type="ProductHotel">
<Code>1499</Code>
<Name>Amic Gala</Name>
<ImageList>
<Image>
<Type>jpg</Type>
<Order>1</Order>
<VisualizationOrder>1</VisualizationOrder>
<Url>http://www.hotelbeds.com/giata/small/00/001499/001499a_hb_w_002.jpg</Url>
</Image>
<Image>
<Type>jpg</Type>
<Order>2</Order>
<VisualizationOrder>2</VisualizationOrder>
<Url>http://www.hotelbeds.com/giata/small/00/001499/001499a_hb_r_005.jpg</Url>
</Image>
</ImageList>
<Category type="SIMPLE" code="3EST" shortname="3*">3 STARS</Category>
<Destination type="SIMPLE" code="PMI">
<Name>Majorca</Name>
<ZoneList>
<Zone type="SIMPLE" code="74">Ca'n Pastilla</Zone>
</ZoneList>
</Destination>
<ChildAge ageFrom="0" ageTo="12"/>
<Position latitude="39.53611999999999682132" longitude="2.71932000000000018147"/>
</HotelInfo>
<AvailableRoom>
<HotelOccupancy>
<RoomCount>1</RoomCount>
<Occupancy>
<AdultCount>2</AdultCount>
<ChildCount>0</ChildCount>
</Occupancy>
</HotelOccupancy>
<HotelRoom SHRUI="azRX8L17pO1vJQ18i8A7+w==" availCount="10" onRequest="N">
<Board type="SIMPLE" code="RO-E10" shortname="RO">ROOM ONLY</Board>
<RoomType type="SIMPLE" code="DBT-E10" characteristic="ST">Double or Twin STANDARD</RoomType>
<ProductType>P</ProductType>
<FreeNights>0</FreeNights>
<Price>
<Amount>94.560</Amount>
<SellingPrice mandatory="Y">94.560</SellingPrice>
<NetPrice>78.960</NetPrice>
<Commission>16.500</Commission>
</Price>
<CancellationPolicies>
<CancellationPolicy amount="94.560" dateFrom="20140505" time="2359"/>
</CancellationPolicies>
</HotelRoom>
</AvailableRoom>
<AvailableRoom>
<HotelOccupancy>
<RoomCount>1</RoomCount>
<Occupancy>
<AdultCount>2</AdultCount>
<ChildCount>0</ChildCount>
</Occupancy>
</HotelOccupancy>
<HotelRoom SHRUI="82LafAHrfGSTNGqn9I45+g==" availCount="10" onRequest="N">
<Board type="SIMPLE" code="BB-E10" shortname="BB">BED AND BREAKFAST</Board>
<RoomType type="SIMPLE" code="DBT-E10" characteristic="ST">Double or Twin STANDARD</RoomType>
<ProductType>P</ProductType>
<FreeNights>0</FreeNights>
<Price>
<Amount>98.560</Amount>
<SellingPrice mandatory="Y">98.560</SellingPrice>
<NetPrice>82.300</NetPrice>
<Commission>16.500</Commission>
</Price>
<CancellationPolicies>
<CancellationPolicy amount="98.560" dateFrom="20140505" time="2359"/>
</CancellationPolicies>
</HotelRoom>
</AvailableRoom>
</ServiceHotel>
示例OutPut
此处我还附上sample Project,请使用此
答案 1 :(得分:1)
请将您的代码更改为
int numberOfPages = 5;
UIScrollView *someScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
someScrollView.pagingEnabled = YES;
//set the scroll view delegate to self so that we can listen for changes
someScrollView.delegate = self;
someScrollView.contentSize = CGSizeMake(numberOfPages * someScrollView.frame.size.width, someScrollView.frame.size.height);
[self.view addSubview:someScrollView];
for (int i = 1; i <= numberOfPages; i++) {
//set the origin of the sub view
CGFloat myOrigin = i * self.view.frame.size.width;
//get the sub view and set the frame
UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(myOrigin, 0, self.view.frame.size.width, someScrollView.frame.size.height)];
imageView1.image = [UIImage imageNamed: [NSString stringWithFormat:@"openingScreen%d.png",i ]];
//add the subview to the scroll view
[someScrollView addSubview:imageView1];
}
添加滚动视图委派方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
}
//dragging ends, please switch off paging to listen for this event
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *) targetContentOffset NS_AVAILABLE_IOS(5_0)
{
//find the page number you are on
CGFloat pageWidth = scrollView.frame.size.width;
int page = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
NSLog(@"Dragging - You are now on page %i",page);
}