小编Kru*_*nal的帖子

如何在iPhone的monotouch中创建SQLite数据库?

我是iPad开发的新手.我使用Xcode 4在Objective C中创建了两个或三个iPad应用程序.现在我想使用C#在MonoDevelop工具中创建iPad应用程序.

我想创建一个基本的数据库项目,因为我需要一个使用SQLite数据库的基础教程.我在Google上搜索过,但我没有得到任何教程.

iphone monodevelop xamarin.ios ipad xcode4.2

3
推荐指数
2
解决办法
5454
查看次数

如何识别在Objective-C中单击了哪个按钮?

我是一名新的iPad开发人员.

我已经以编程方式创建了UIButton,我希望识别用户已经点击了哪个按钮,并根据我想要做一些动作.

我应该如何识别这个?

这是我的代码片段:

for(int i=0;i<[_array count];i++)
    {

        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        button.tag=count;
        [button addTarget:self 
                   action:@selector(aMethod:)
         forControlEvents:UIControlEventTouchDown];

        button.backgroundColor=[UIColor redColor];
        [button setTitle:@"Show View" forState:UIControlStateNormal];
        button.frame = CGRectMake(xpos, 270.0, 200.0, 150.0);

        [self.view addSubview:button];            
    }
Run Code Online (Sandbox Code Playgroud)

这就是我现在正在做的事情:我想我会为每个按钮分配计数,然后我会将此计数传递给按钮点击方法.这是一个好主意吗?还有其他方法吗?

在按钮上单击我正在呼叫aMethod:

-(void)aMethod:(id)sender{
    NSLog(@"btn clicked");

}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!

iphone uibutton sender ipad ios

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

uiwebview不滚动到底部

我是iPad开发人员的新手,

我正在为我的应用程序制作ePub阅读器,我正在加载我的ePub页面 UIWebView

当我加载我的页面时,webview只滚动到一些限制,

这是我的代码片段,

- (void)viewDidLoad {
...

    _webview=[[UIWebView alloc]init];
    _webview.frame=CGRectMake(0, 0, 770, 960);
    [_webview setBackgroundColor:[UIColor grayColor]];
    _webview.delegate=self;
    [self.view addSubview:_webview];

    [self loadPage];
...
}



 - (void)loadPage{

  [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]];

    [self._webview sizeToFit];
    _webview.scalesPageToFit=TRUE;
    _webview.scrollView.bounces = NO;
    _webview.autoresizesSubviews = YES;

}
Run Code Online (Sandbox Code Playgroud)

iphone load uiwebview epub ipad

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

检测UIWebview中的滑动手势

我是iPhone开发人员,

我制作了epub阅读器并加载了我的每一页epub webview

我想要的是,当用户做right swipe gesture第二次然后我想导航到新页面时,我不想在用户right swipe gesture第一次做任何事情时做任何事情.

UISwipeGestureRecognizer *swipeRight

有什么方法,比如

if(swipeRight.touch.count > 2)
{
  // do this
}
Run Code Online (Sandbox Code Playgroud)

任何帮助都会得到满足.

提前致谢 !

编辑

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    float scrollViewHeight = scrollView.frame.size.height;
    float scrollContentSizeHeight = scrollView.contentSize.height;
    float scrollOffset = scrollView.contentOffset.y;

    if (scrollOffset == 0)
    {
        swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeLeftAction:)];
        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
        swipeUp.numberOfTouchesRequired=2;
        swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
        swipeUp.cancelsTouchesInView=YES;
        [_webview addGestureRecognizer:swipeUp];  
    }
    else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
    {
        swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];
        swipeDown.direction …
Run Code Online (Sandbox Code Playgroud)

iphone uiwebview touchesmoved ipad uigesturerecognizer

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

当用户在UISearchBar中停止输入时检测暂停

我有以下UISearchbar代码:

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    NSTimer *myTimer;

    NSLog(@"Timer=%@",myTimer);
    if (myTimer)
    {
        if ([myTimer isValid])
        {
            [myTimer invalidate];
        }
        myTimer=nil;
    }
    myTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(OnTextChange) userInfo:nil repeats:NO];

}
Run Code Online (Sandbox Code Playgroud)

写完上面代码后我的日志显示Timer=null,

OnTextChange 是从Url获​​取数据的方法.

提前致谢 !!

iphone nstimer uisearchbar ipad ios

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

智能应用横幅不工作iOS

我已经在我的网站的主页中写了这个代码,我在我的iPhone 4s中使用iOS 6.1.3,当我在safari中访问我的网站时,最初有一个加载的横幅出现在屏幕顶部然后一段时间后(意味着加载完整的网站后) )横幅消失:(

这是我在网站上写的代码,

<meta name="apple-itunes-app" content="app-id=68924633, affiliate-data=myAffiliateData, app-argument=https://itunes.apple.com/gb/app/bi/id68924637?mt=8&uo=4">

提前致谢.

iphone safari banner ipad ios

3
推荐指数
2
解决办法
7686
查看次数

iOS 7 UINavigationBar背景图片隐藏标题视图

我制作了iOS应用,我希望我的应用与iOS 7兼容

其中我面临的问题是,当我在iOS 7上运行我的应用程序,我的背景图像UINavigationBar兽皮我的titleviewback button

截图在这里:

-(void)viewDidLoad
{
    [super viewDidLoad];

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"top.png"] forBarMetrics:UIBarMetricsDefault];

    self.title=@"Artist";
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];


}
Run Code Online (Sandbox Code Playgroud)

同样,当我将背景图像设置UINavigationBar为nil时,它显示titleviewback button

当我在iOS 7之前运行我的应用程序时,它可以正常工作.

请帮忙. 提前致谢.

iphone objective-c ipad ios ios7

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

在iOS中未收到FCM通知

我一直试图在我的ios应用程序中获取firebase推送通知很长一段时间.我已经尝试了我能找到的互联网上的一切.但遗憾的是没有运气.任何帮助,将不胜感激.

我通过firebase控制台发送通知.

这是我的代码:

#import "AppDelegate.h"

#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@import UserNotifications;
#endif

@import Firebase;
@import FirebaseInstanceID;
@import FirebaseMessaging;

#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
@interface AppDelegate () <UNUserNotificationCenterDelegate, FIRMessagingDelegate>
@end
#endif

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    // [START configure_firebase]
    [FIRApp configure];
    // [END configure_firebase]

    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) {
        UIUserNotificationType allNotificationTypes =
        (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge);
        UIUserNotificationSettings *settings =
        [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    } …
Run Code Online (Sandbox Code Playgroud)

objective-c ios google-cloud-messaging firebase-cloud-messaging

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

将xcode 4.6 iPhone应用程序转换为通用应用程序

我正在尝试将我现有的iPhone应用程序项目升级到通用应用程序,我已经实现了以下步骤,

第1步: Project Navigator - 目标 - 摘要 - 设备 - 通用(从iPhone到通用)

第2步:在Storyboard中使用NavigationBar Flow创建TabBar,

当我在iPhone中运行我的项目时,它可以正常工作,但是当我在iPad上运行时,它只显示带有NavigationBar的TabBar.

现在我的问题是如何.xib为iPad 创建新文件?当我从iPhone到Universal选择我的设备时,Xocde不会自动创建.

要么

如何.xib使用iPad 映射我的iPhone 文件.

我是否需要为iPhone中的所有按钮创建新的插座和操作.xib

提前致谢.

iphone xcode objective-c ipad ios

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

removeAllObjects崩溃应用程序

我想清除我的阵列,我做的是,

我在我的应用程序中有tableview视图,首先我从服务器获取数据并将其加载到tableView中.

-(void)viewDidLoad{

  //fetching data from server using background thread and storing it in array called (msg_array)
  [table reloadData];

}
Run Code Online (Sandbox Code Playgroud)

当最后一行出现在屏幕上时,我想从服务器获取新数据,我想显示它,

-(void)LoadMoreData{ //this method gets fire when last cell is on screen 

    if ([msg_array count]>0) 
    {
        [msg_array removeAllObjects];  //crashes here
    }

}
Run Code Online (Sandbox Code Playgroud)

这给出了错误:

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

为什么会导致崩溃:

数组的分配方式如下:

msg_array = [dictShow copy];
Run Code Online (Sandbox Code Playgroud)

dictshow包含数据并将其复制到msg_array,而dictshow是mutabledictionary

(摘自评论)

iphone objective-c nsarray ipad ios

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