小编Ale*_* R.的帖子

突出显示时,iOS7自定义按钮变为透明

我只是创建自己的自定义按钮,看起来像iOS6和更早的按钮,但在iOS7上我的CustomButton突出显示时变为透明.我试着设置属性adjustsImageWhenHighlighted在NO但没有任何改变,[self setAlpha:1.f]也不起作用.

以下是我的init方法:

-(void) baseInit:(CGRect)frame :(CGFloat *)colorsNormal :(CGFloat *)colorsHighlighted :(CGFloat *)colorsDisabled
{

    self.layer.borderWidth=1.0f;
    self.layer.borderColor=[[UIColor colorWithRed:0.67f green:0.67f blue:0.67f alpha:1.0f] CGColor];
    self.layer.cornerRadius=7.0f;

    self.clipsToBounds = YES;

    UIImage *image = [self generateUIImageWithGradient:frame :colorsNormal];
    [self setBackgroundImage:image forState:UIControlStateNormal];
    [self setTitleColor:[UIColor colorWithRed:0.22f green:0.33f blue:0.53f alpha:1.0f] forState:UIControlStateNormal];

    UIImage *image2 = [self generateUIImageWithGradient:frame :colorsHighlighted];
    [self setBackgroundImage:image2 forState:UIControlStateHighlighted];
    [self setTitleColor:[UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f] forState:UIControlStateHighlighted];

    UIImage *image3 = [self generateUIImageWithGradient:frame :colorsDisabled];
    [self setBackgroundImage:image3 forState:UIControlStateDisabled];
}

-(id) generateUIImageWithGradient:(CGRect)frame :(CGFloat *)colors
{
    CGSize size = CGSizeMake(frame.size.width, frame.size.height);
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    CGContextRef context …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios

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

从星期几整数java获取日期字符串

我需要得到只有一周整数的一天字符串(例如:1 =星期一,5 =星期五......),我没有任何日期.

我知道我可以定义一个字符串数组,但我认为使用日期格式有更好的解决方案.没有约会可能吗?

java android date

4
推荐指数
2
解决办法
4929
查看次数

Objective-c/iOS - 使用Safari打开本地html文件

我有一个HTML文件保存在一个临时目录中,如下所示:

NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *documentDirectory = NSTemporaryDirectory();
NSString *documentPath = [documentDirectory stringByAppendingPathComponent:@"mydocument.html"];
[fileManager createFileAtPath:documentPath contents:myHTMLDocumentData attributes:nil];
Run Code Online (Sandbox Code Playgroud)

该文档在我的临时文件中创建.在它之后,我想在Safari中打开这个文档,但它不起作用:

NSURL *url = [NSURL fileURLWithPath:documentPath];
[[UIApplication sharedApplication] openURL:url];
Run Code Online (Sandbox Code Playgroud)

屏幕上没有任何事情发生,没有错误......但是,如果我用@"http://google.fr"替换"url",则会使用google.fr启动Safari,我可以通过输入网址来访问我的临时文件" Safari中的文件://localhost..../myHtmlDocument.html".

希望你能帮我

safari cocoa-touch objective-c ios

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

ArrayAdapter要求资源ID为DialogFragment中的TextView

我在DialogFragment中使用ArrayAdapter,可以在Android 4.0及更高版本上运行,但在2.3版本中不行.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    View view = inflater.inflate(R.layout.dialog, null);

    Spinner spReglement;
    spReglement = (Spinner)view.findViewById(R.id.listReglements);

    ArrayAdapter<String> adapterList = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1);
    adapterList.setDropDownViewResource(R.layout.customspinner);
    spReglement.setAdapter(adapterList);

    HashMap<Integer, String> mapReglement = new HashMap<Integer, String>();
    mapReglement.put(-1, "");
    adapterList.add("");
    for(int i=0; i<alReglement.size();i++){
        String libelle = String.valueOf(alReglement.get(i).get("Libelle"));         
        mapReglement.put(i, libelle);
        adapterList.add(libelle);           
    }
    builder.setView(view)
           .setPositiveButton("Valider", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                   mListener.onDialogPositiveClick(DialogFSE.this);
               }
           })
           .setNegativeButton("Annuler", new DialogInterface.OnClickListener() { …
Run Code Online (Sandbox Code Playgroud)

java android android-arrayadapter android-dialogfragment

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