小编Adr*_*lli的帖子

同一TextView中字符串的字体大小不同

我有一个textView带有数字(变量)和a的内部string,我怎么能给出比这个大一号的string?代码:

TextView size = (TextView)convertView.findViewById(R.id.privarea_list_size);
if (ls.numProducts != null) {
    size.setText(ls.numProducts + " " + mContext.getString(R.string.products));
}
Run Code Online (Sandbox Code Playgroud)

我想ls.numproducts的大小与文本的其余部分不同.怎么做?

string android textview text-size

130
推荐指数
5
解决办法
9万
查看次数

NSInternalInconsistencyException',原因:'无法在bundle中加载NIB:'NSBundle

在我的AppDelegate中有一个我不明白的问题.RootViewController最初调用了ViewController,我改名了.该应用程序由许多ViewController组成,然后我介绍了一个UINavigationController.为什么会出现此错误?

  NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle 
  /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/
  B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name 
 'RootViewController''

  *** First throw call stack:
  (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0
  x380b2a  0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab 
  0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf 
  0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 0x2d8922 0x382fec 0x2cfbc4 0x2cfdbf 
  0x2cff55 0x2d8f67 0x2b30 0x29c7b7 0x29cda7 0x29dfab 0x2af315 0x2b024b 0x2a1cf8 
  0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da
  0x29f65c 0x269d 0x25c5) 
  ibc++abi.dylib: terminate called throwing …
Run Code Online (Sandbox Code Playgroud)

compiler-errors nib ios appdelegate

45
推荐指数
8
解决办法
13万
查看次数

在CALayer中添加UIImage

我必须添加一个UIImageView作为MapView的子视图.为此,我在MapView上创建了一个图层.在这一层,我想放置我的图像,但我得到一个白色的矩形,没有别的.我的图片不可见.

这是代码:

- (void)viewDidLoad
{
    //......

    CALayer *layer = [CALayer layer];
    layer.backgroundColor = [[UIColor whiteColor] CGColor];

    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        layer.bounds = CGRectMake(self.mapView.bounds.origin.x,
                                  self.mapView.bounds.origin.y, 80, 300);
    }
    else
    {
        layer.bounds = CGRectMake(self.mapView.frame.origin.x,
                                  self.mapView.frame.origin.y, 150, 700);
    }

    layer.contents = (id)[UIImage imageNamed:@"myImage.png"];
    //the name is correct but  in the output the image is not visible

    [[self.mapView layer] addSublayer:layer];
    [layer setNeedsDisplay];
}
Run Code Online (Sandbox Code Playgroud)

subview calayer uiimageview uiimage ios

40
推荐指数
3
解决办法
4万
查看次数

IndexOfObject返回2147483647

我有一个包含10个项目的数组.当我IndexOfObject为元素编号9 调用" "时,元素编号10 Xcode返回异常:" NSRangeException"

原因:'_ [_ NSCFArray objectAtIndex:]索引:2147483647超出边界(10)'.

从前一个NSLog,我看到数组中存在两个元素,但indexOfObject没有找到它们.为什么?

我的代码是:

    NSDictionary * headConfig =[avatarDictionaryToSave objectForKey:@"head_dictionary"];
    NSString * headImage =[headConfig objectForKey:@"layer_key"];
    NSString * pathFace =[[NSBundle mainBundle]pathForResource:@"Face" ofType:@"plist"];
    NSLog(@"%@", headImage);

    NSArray *arrayFace =[NSArray arrayWithContentsOfFile:pathFace];
    NSLog(@"the  elements are: %@", arrayFace);//here headImage is present
    int index =[arrayFace indexOfObject:headImage];
    NSLog(@"the index is %d", index);
Run Code Online (Sandbox Code Playgroud)

iphone nsarray nsrangeexception

12
推荐指数
1
解决办法
1万
查看次数

对于关键视图,此类不符合键值编码.

我在AppDelegate中遇到问题,运行应用程序时出现此错误:

  Terminating app due to uncaught exception 'NSUnknownKeyException', reason: 
  '[<UIApplication 0x856c820> setValue:forUndefinedKey:]:
   this class is not key value coding-compliant for the key view.'
Run Code Online (Sandbox Code Playgroud)

这是AppDelegate.h的代码

#import <UIKit/UIKit.h>

@class ViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>{

        //UINavigationController *navigationController;
 }

@property (strong, nonatomic) UIWindow *window;


@property (copy, nonatomic) ViewController * viewController;
@property (copy, nonatomic) UINavigationController * navigationController;



 @end
Run Code Online (Sandbox Code Playgroud)

这是AppDelegate.m的代码

 #import "AppDelegate.h"

 #import "RootViewController.h"



  @implementation AppDelegate



  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
   {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

        RootViewController *rootMenu;


         if ([[UIDevice currentDevice] …
Run Code Online (Sandbox Code Playgroud)

compiler-errors ios ios-universal-app appdelegate

11
推荐指数
1
解决办法
1万
查看次数

此类不是键值imageView的键值编码兼容

我的应用程序的RootViewController有问题.当我运行应用程序时,我收到此错误.这意味着什么?

  NSUnknownKeyException', reason: '[<UIApplication 0x8634010> setValue:forUndefinedKey:]:     this class is not key value coding-compliant for the key bigImageView.'
 First throw call stack:
 (0x1992012 0x1357e7e 0x1a1afb1 0xe04711 0xd85ec8 0xd859b7 0xdb0428 0x4bc0cc
 0x136b663 0x198d45a 0x4babcf 0x4bc98d 0x29eceb 0x29f002 0x29ded6 0x2af315 0x2b024b 
 0x2a1cf8 0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da 0x29f65c 0x2c6d 0x2b95)   
 libc++abi.dylib: terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)

我在RootViewController.h中的代码

  #import <UIKit/UIKit.h>


  @interface RootViewController : UIViewController <UIGestureRecognizerDelegate>{

  }

 @property (nonatomic, copy)IBOutlet UIImageView * bigImageView;
 @property (nonatomic, assign)BOOL fromRootViewController;


 - (void)handleTap:(UITapGestureRecognizer *)recognizer;



 @end
Run Code Online (Sandbox Code Playgroud)

我在RootViewController.m中的代码 …

compiler-errors exception iboutlet ios

8
推荐指数
2
解决办法
9345
查看次数

onCreateView Fragment未调用

我有一个DialogFragment 带有FrameLayout容器的自定义,我想放一个容器,Fragment但它的视图总是返回null,我该怎么办?

DialogCreateAccount.java

   public class DialogCreateAccount extends DialogGeneral implements OnClickListener{

   @Override
   public Dialog onCreateDialog(Bundle savedInstanceState) {
    // TODO Auto-generated method stub

    Dialog dialog = super.onCreateDialog(savedInstanceState);

    //........


    return dialog;

   }


@Override
public void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

     Fragment fragment = CreateAccountFragment.newInstance();


     FragmentTransaction ft = getFragmentManager().beginTransaction();

         if(fragment.getView()!=null){ // return always null

            ft.add(
                    getFrameContainer().getId(),
                    fragment
                    )
            .commit();
         }else{

         }

        Log.i("DialogCreateAccount", "fragment:" +fragment.getView());// return null
  }
Run Code Online (Sandbox Code Playgroud)

在CreateAccountFragment.java中

 public class CreateAccountFragment extends …
Run Code Online (Sandbox Code Playgroud)

java android android-fragments android-dialogfragment

8
推荐指数
1
解决办法
2万
查看次数

UIButton在uiscrollView中不起作用

我有一个scrollView具有UIView作为子视图.这有UIView子视图a UIButton.只有scrollView连接到插座,其余全部都是代码.按钮不响应触摸,触摸时不变蓝.我能做些什么才能让它发挥作用?

这是代码:

   - (void)viewDidLoad
 {
       [super viewDidLoad];

      //......

      self.buttonHome = [UIButton buttonWithType:UIButtonTypeCustom];
      [self.buttonHome addTarget:self action:@selector(pressedHome:)
                                  forControlEvents:UIControlEventTouchUpInside];
      //....
      self.containerView =[[UIView alloc]initWithFrame:self.scrollView.frame];
      self.containerView.userInteractionEnabled=YES;

      [self.scrollView addSubview:self.containerView];
      [self.containerView addSubview:self.buttonHome];
  }

  -(void) pressedHome:(id)sender{
         //....
  }
Run Code Online (Sandbox Code Playgroud)

uibutton uiscrollview uiview ios

7
推荐指数
1
解决办法
9234
查看次数

从另一个ViewController调用方法

我有一个ViewControllerA和一个ViewControllerB.我想从ViewControllerB调用ViewControllerA的方法.

在ViewControllerA中有一个方法:

  -(NSMutableArray*) loadData;
Run Code Online (Sandbox Code Playgroud)

在ViewControllerB.h中:

 #import "ViewControllerA.h"
  .......
 @property (nonatomic, strong) ViewControllerA * viewControllerA;
 @property (nonatomic, strong) NSMutableArray * mutableArray;
Run Code Online (Sandbox Code Playgroud)

在ViewControllerB.m中:

self.mutableArray =[viewControllerA loadData];
Run Code Online (Sandbox Code Playgroud)

但方法不是调用.为什么?提前致谢

iphone methods uiviewcontroller ios

6
推荐指数
1
解决办法
1万
查看次数

我无法在NetBeans中看到android的图形布局

当我在NetBeans中打开main.xml文件时,我无法看到Eclipse中发生的图形布局.我该怎么做才能搞定?我要安装一些东西?提前致谢

android android-layout netbeans-7

5
推荐指数
1
解决办法
8172
查看次数

NSInvalidArgumentException:发送到实例的无法识别的选择器

当我运行我的应用程序时,我收到此错误:

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
     [UIRoundedRectButton copyWithZone:]: unrecognized selector sent to instance
     0xcc86970'
Run Code Online (Sandbox Code Playgroud)

为什么我会收到这样的错误?我小心翼翼地检查IBOutlets的所有连接e所有IBAction.这是我的代码:

MenuViewController.h

     @interface MenuViewController : UIViewController
<UITableViewDelegate, UITableViewDataSource>{

}


@property (nonatomic, copy) IBOutlet UITableView * tableView;
@property (nonatomic,copy) IBOutlet UILabel *labelTitle;
@property (nonatomic, copy) IBOutlet UIButton *buttonHome;
@property (nonatomic, copy) IBOutlet UIButton *buttonMap;
@property (nonatomic, copy) IBOutlet UIButton *buttonFavorites;

 -(IBAction) pressedHome:(id)sender;
-(IBAction) pressedMap: (id)sender;
-(IBAction) pressedFavorites: (id)sender;

 @end
Run Code Online (Sandbox Code Playgroud)

在MenuViewController.m中

 -(IBAction) pressedHome:(id)sender{

     MenuViewController * menu =[[MenuViewController alloc]initWithNibName:@"MenuViewController" bundle:nil];
   [self.navigationController pushViewController:menu animated:YES];


    }

  -(IBAction) …
Run Code Online (Sandbox Code Playgroud)

variables compiler-errors iboutlet ios

1
推荐指数
1
解决办法
3625
查看次数

目标C中的逻辑运算符和错误结果

我通过屏幕上设置的UITapGestureRecognizer获得了x和y,在获得了我找到对象触摸的位置后,所以我把条件,但不起作用.也许我把错误的条件放在目标C中?Xcode没有错误,但功能不起作用.

  -(void)tappedMapOniPad:(int)x andy:(int)y{
       NSLog(@"the x is: %d", x);
         //the x is: 302
       NSLog(@"the y is: %d", y);
         //the y is: 37

       if((121<x<=181) && (8<y<=51)){ //the error is here
            self.stand = 431;
        }else if ((181<x<=257) && (8<y<=51)){
            self.stand=430;
        }else if ((257<x<=330) && (8<y<=51)){
            self.stand = 429;
        }

      NSLog(@"The stand is %d", self.stand);
        //The stand is 431

   }
Run Code Online (Sandbox Code Playgroud)

我能怎么做?

logic objective-c ios

0
推荐指数
1
解决办法
490
查看次数