我UIPageViewController在iPad上使用,我需要firstviewController在第一页和ContentViewController下一页的横向显示.
如果我设置了NSArray两个viewControllers应用程序崩溃,[self.pagviewController setViewController:]则出现以下异常:
提供的视图控制器(2)的数量与请求的脊椎位置所需的数量(1)不匹配(UIPageViewControllerSpineLocationMin)
以下是代码:
#pragma mark - UIPageViewControllerDataSource Methods
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == 0)
{
return nil;
}
ContentViewController *contentViewController = [[ContentViewController alloc] init];
contentViewController.textContents = [self.modelArray objectAtIndex:currentIndex - 1];
return contentViewController;
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger currentIndex = [self.modelArray indexOfObject:[(ContentViewController *)viewController textContents]];
if(currentIndex == self.modelArray.count-1)
{
return nil;
}
ContentViewController …Run Code Online (Sandbox Code Playgroud) 我想在safari中打开一个url,超出应用程序,而不是在webview中.
我实现了UIWebViewDelegate,但我仍然无法打开网址.基本上我无法点击网址.
以下是代码:
-(void)newView:(NSString *)title Description:(NSString *)desc URL:(NSString *)url{
webView =[[UIWebView alloc]initWithFrame:CGRectMake(15, 17, 190, 190)];
webView.backgroundColor=[UIColor clearColor];
webView.delegate=self;
webView.opaque = NO;
[webView loadHTMLString:[NSString stringWithFormat:@"<html><body p style='color:white' text=\"#FFFFFF\" face=\"Bookman Old Style, Book Antiqua, Garamond\" size=\"5\">%@ %@</body></html>", desc,url] baseURL:nil];
v = [[HUDView alloc] initWithFrame:CGRectMake(60, 70, 220, 220)];
cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
cancelButton.frame = CGRectMake(0, 0, 30, 30);
[cancelButton setBackgroundImage:[UIImage imageNamed:@"closebox.png"] forState:UIControlStateNormal];
[cancelButton addTarget:self action:@selector(cancelButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[v addSubview:cancelButton];
[v addSubview:webView];
[self.view addSubview:v];
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if …Run Code Online (Sandbox Code Playgroud) 我有一个相对布局,并在我的水平滚动视图中以编程方式添加imageview,放在xml中.当我尝试在horizontalScrollView ..im中添加我的imageview时获得运行时异常.HorizontalScrollView只能托管一个孩子.你能不能帮助我出
RelativeLayout.LayoutParams HParams = new RelativeLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
HParams.topMargin = 200 * displayHeight / 480;
HsrollView.setLayoutParams(HParams);
for (int i = 0; i < 4; i++) {
ImageView btnTag = new ImageView(this);
btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
btnTag.setImageResource(R.drawable.book);
btnTag.setTag(i);
btnTag.setId(i);
HsrollView.addView(btnTag);
}
Run Code Online (Sandbox Code Playgroud)
XML文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/directbg"
tools:context=".DirectorActivity" >
<HorizontalScrollView
android:id="@+id/Hscrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个视图控制器.当我传递一个额外的对象我得到这个错误@No可见界面在下面的函数.你可以帮助我.下面是code.where我传递类型照片的对象..
ItemImageView *itemImage = [[ItemImageView alloc]initWithFrame:CGRectMake(currentPhotoPositionX,0,pageButtonWidth,pageButtonHeight) andPhoto:photo];
@ItemImageview
- (id)initWithFrame:(CGRect)frame :andPhoto:(Photo *)photo
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
//Create Activity Indicator
activityIndicator= [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(225, 115, 30, 30)];
[activityIndicator setBackgroundColor:[UIColor clearColor]];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[self addSubview:activityIndicator];
//Create Label Comments
lblComments = [[UILabel alloc] initWithFrame:CGRectMake(30.0f, 100.0f, 60.0f, 43.0f)];
[lblComments setText:@"Comments"];
[lblComments setBackgroundColor:[UIColor clearColor]];
[self addSubview:lblComments];
//Create Label Likes
lblLikes = [[UILabel alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 60.0f, 43.0f)];
[lblLikes setText:@"Likes"];
[lblLikes setBackgroundColor:[UIColor clearColor]];
[self addSubview:lblLikes];
//Create Item Button
btnItem = …Run Code Online (Sandbox Code Playgroud)