小编Sag*_*...的帖子

当我们点击UISearchBar时会调用哪个事件

在我的应用程序中,当我单击在视图上添加的UISearchbar时,我需要执行一些活动,即推送otherview控制器.

什么是实现这一目标的最佳方法.

有一件事是当我们点击UISearchbar"searchBarTextDidBeginEditing"被解雇时,但是当我在"searchBarTextDidBeginEditing"中推送视图控制器并返回searchBarTextDidBeginEditing再次调用时,我的场景似乎不是推送视图控制器的理想位置.

这是主控制器

// Search bar
  iSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 40)];
  iSearchBar.delegate = self;
  iSearchBar.showsCancelButton = NO;
  iSearchBar.autocorrectionType = UITextAutocorrectionTypeNo;
  iSearchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  [self addSubview:iSearchBar];
Run Code Online (Sandbox Code Playgroud)

当我点击UISearchBar然后它调用

   - (void)searchBarTextDidBeginEditing:(UISearchBar*)searchBar
   {
   [self ShowMySearch];
   }
Run Code Online (Sandbox Code Playgroud)

在ShowMySearch中,我推动其他一些控制器让我们说搜索控制器,当弹出这个搜索控制器并返回主控制器"searchBarTextDidBeginEditing"再次调用并再次推送搜索控制器并导致问题.这种行为仅在3.1.1上看到

谢谢,

萨加尔

iphone uisearchbar ipad

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

<Error>:CGContextSaveGState:无效的上下文0x0错误

我得到了一些与准备UIImage一个相关的问题UIView.我有时(但不总是)看到错误

<Error>: CGContextSaveGState: invalid context 0x0
Run Code Online (Sandbox Code Playgroud)

我正在使用iPhone SDK 4.0.我的代码:

-(void)drawRect:(CGRect)rect
{
     // Customized to draw some text
}


-(UIImage*) PrepareBackImage:(CGRect) aRect // aRect = (0,0,1800,1200)
{
    UIImage* background;

    background      = [self GetImageFromView:self toRect:self.frame];
    UIGraphicsBeginImageContext(aRect.size);

    CGPoint backgroundPoint = CGPointMake(0,0);
    [background drawAtPoint:backgroundPoint];

    UIImage* backImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return backImage;
}

- (UIImage *) GetImageFromView:(UIView *)aView toRect:(CGRect)aRect
{
    CGSize pageSize = aRect.size;
    UIGraphicsBeginImageContext(pageSize);
    [aView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}
Run Code Online (Sandbox Code Playgroud)

iphone uiview cgcontext ios

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

autocapitalizationType不起作用

我试图通过设置autocapitalizationType保持textFiled"Capital"的第一个字符,但它不起作用.下面是src代码的快照.

UITextField* returnTextField = [[UITextField alloc] initWithFrame:frame];
returnTextField.autocorrectionType = UITextAutocorrectionTypeNo;
returnTextField.autocapitalizationType = UITextAutocapitalizationTypeWords;
returnTextField.keyboardType = UIKeyboardTypeEmailAddress;
returnTextField.returnKeyType = UIReturnKeyGo;
returnTextField.clearButtonMode = UITextFieldViewModeWhileEditing;  
returnTextField.delegate = self;
Run Code Online (Sandbox Code Playgroud)

谢谢,

萨加尔

uitextfield ios4

9
推荐指数
4
解决办法
3949
查看次数

推出面向IPad的横向应用

面向IPad启动横向应用的一个问题.我开发了IPhone应用程序,后来我移植到IPad.

我已经在info.plist中设置了关于方向的设置

[ UISupportedInterfaceOrientations~ipad ] to support all orientation UIInterfaceOrientationPortrait , UIInterfaceOrientationPortraitUpsideDown , UIInterfaceOrientationLandscapeLeft , UIInterfaceOrientationLandscapeRight.
Run Code Online (Sandbox Code Playgroud)

但是当我在横向模式下启动IPad应用程序时,它总是以potrait模式启动.

沿着这个

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{ return YES; }
Run Code Online (Sandbox Code Playgroud)

帮助我,如果我错过了这个...

谢谢,

萨加尔

iphone ipad

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

iOS 4 + MPMoviePlayerController

我开发了可在IPad和IPhone上运行的通用应用程序.我在这里使用MPMoviePlayerController的一个组件.

现在iOS4发布了,今天我得到了一个关于我的应用程序拒绝的坏消息,因为这个MPMoviePlayerController崩溃了.

iDemoPlayer= [[MPMoviePlayerController alloc] initWithContentURL:aUrl];
[iDemoPlayer play];
Run Code Online (Sandbox Code Playgroud)

这是我播放视频的src代码.

在iPhone OS 4.0版本中我发现了

"如果您将Universal应用程序与iPhone SDK 3.2相关联,则必须准备好在iOS 4及更高版本上运行时在您的界面中嵌入电影播放器​​视图"

REF

http://developer.apple.com/iphone/library/releasenotes/General/RN-iPhoneSDK-4_0/index.html

你能帮助我吗,我需要做什么更新才能再次被接受!!!!!!

谢谢,

萨加尔

iphone ipad

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

由于PostNotification导致的EXC_BAD_ACCESS

我正面临一个关于一个模块的问题让我清楚了解相同的流程.

我有一个定制的UITableviewCell.

当我收到一些新信息时,我发布了一条通知

[[NSNotificationCenter defaultCenter] postNotificationName:KGotSomething object:nil userInfo:message];
Run Code Online (Sandbox Code Playgroud)

鉴于我在维护表格,我正在启动一个自定义单元格

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell= [[CustomCell alloc] initWithFrame: reuseIdentifier:identifier document:doc];
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

现在在customcell.mm

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier 
{
[[NSNotificationCenter defaultCenter] addObserver:self 
                 selector:@selector(GotSomething:) 
                         name:KGotSomething 
                        object:nil];
}
Run Code Online (Sandbox Code Playgroud)

并在dealloc

- (void)dealloc 
{
    [[NSNotificationCenter defaultCenter] removeObserver:self
                    name:KGotSomething 
                       object:nil];
}
Run Code Online (Sandbox Code Playgroud)

现在我的应用程序由于此通知而崩溃,并且永远不会调用dealloc.

你们可以帮助我,如何让这个工作或者我在这里做错什么......

谢谢,

萨加尔

iphone ipad

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

如何通过FindWindow api调用在C#中开发的窗口

我是C#和xaml代码的新手.我有一个用C#实现的示例代码.当我查看了xaml文件时,我得到了<Window x:Class="test.MainWindow">.

所以确实test.MainWindow指出了这个窗口的类名.

我试图从win 32中开发的其他应用程序调用此窗口.我试图将此类名称传递给FindWindow("test.MainWindow",NULL),但它失败了.在那边做了什么遗失.

如何更改C#中开发的窗口的类名?

谢谢,

萨加尔

c# wpf winapi xaml

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

从 Document 文件夹中读取 UIImage

我需要从文档文件夹中读取图像并从中准备 UIImage。但是当我每次内存增加时调用这个函数并且对于大尺寸图像来说这个比例很大。以下是相同的代码

-(UIImage*) GetSavedImageWithName:(NSString*) aFileName
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSMutableString* str = [[NSMutableString alloc] initWithCapacity:300];
    [str appendString:documentsDirectory];
    [str appendString:@"/"];
    [str appendString:aFileName];

    NSFileManager *fileManager = [NSFileManager defaultManager];
    BOOL success = [fileManager fileExistsAtPath:str];

    NSData *dataToWrite = nil;

    UIImage* image = nil; 

    if(!success)
    {

    }
    else 
    {
        dataToWrite = [[NSData alloc] initWithContentsOfFile:str];  
        image = [UIImage imageWithData:dataToWrite];                                                                                                                                                                                               YES;
    }
    if(dataToWrite)
    {
        [dataToWrite release];
        dataToWrite = nil;
    }

    if(str)
    {
        [str release];
        str = nil;
    }

    if(fileManager) …
Run Code Online (Sandbox Code Playgroud)

iphone

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

截取具有CATransform3DMakeRotation子视图的UIView的屏幕截图

我正在尝试生成具有子视图的UIView的屏幕截图CATransform3DMakeRotation.屏幕截图已生成,但不包含"旋转".

是否有可能实现这一目标?

实际观点:

在此输入图像描述

ScreenShot图像

在此输入图像描述

使用以下调用水平翻转视图...

  currentView.layer.transform = CATransform3DConcat(currentView.layer.transform,CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0f));
Run Code Online (Sandbox Code Playgroud)

拍摄屏幕截图的代码

+ (UIImage *) imageWithView:(UIView *)view
{
    CGSize screenDimensions = view.bounds.size;

    // Create a graphics context with the target size
    // (last parameter takes scale into account)
    UIGraphicsBeginImageContextWithOptions(screenDimensions, NO, 0);

    // Render the view to a new context
    CGContextRef context = UIGraphicsGetCurrentContext();
    [view.layer renderInContext:context];

    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();

    return img;
}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios

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

标签 统计

iphone ×6

ipad ×4

ios ×2

c# ×1

cgcontext ×1

cocoa-touch ×1

ios4 ×1

objective-c ×1

uisearchbar ×1

uitextfield ×1

uiview ×1

winapi ×1

wpf ×1

xaml ×1