小编jim*_*sis的帖子

iOS MapKit更改mapview maptype会导致注释图像更改为pin吗?

任何有关以下问题的建议都将受到赞赏.

我正在使用以下代码将自定义图像添加到注释中.

- (MKAnnotationView *)mapView:(MKMapView *)mapView 
            viewForAnnotation:(id <MKAnnotation>)annotation
{
    if ([annotation isMemberOfClass:[MKUserLocation class]]) 
    { 
        return nil; 
    } 


    if ([annotation isMemberOfClass:[SpectatorPin class]]) 
    { 
        SpectatorPin *sp = (SpectatorPin *)annotation;
        MKAnnotationView *view = [self.mapView dequeueReusableAnnotationViewWithIdentifier:@"specPin"];
        if (view == nil) {
            view = [[[MKPinAnnotationView alloc] initWithAnnotation:sp reuseIdentifier:@"specPin"] autorelease];
        }
        view.image = [UIImage imageNamed:@"mylocation20x20.png"]; 
        view.canShowCallout = YES;
        view.annotation=annotation;
        return view;
    }

    //Should not get here
    return nil;

}
Run Code Online (Sandbox Code Playgroud)

最初正确显示图像.

我有一个段控件,可以更改地图类型(标准,卫星,混合).标准是默认值.一旦我选择卫星,图像立即变为一个引脚.不再调用mapView:viewforAnnotation方法.

问候,

吉姆

uiimage mapkit mkannotation mkannotationview ios

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

如何将cursorLoader强制转换为Loader <Object>

希望简单的java问题我只是忘记或永远不会理解.我一直在玩Android 4.0中的Loaders.该计划正在按原样运作,但现在我正在寻找"下一个"部分.我想要一个标准的Cursor加载器和一个自定义的AsyncTaskLoader.我坚持第1部分试图将cursorLoader转换为Loader并返回它.

@Override
    //public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    public Loader<Object> onCreateLoader(int id, Bundle args) {

        if (id == LISTVIEWLOADER) {
            String[] projection = { RunnerTable.COLUMN_ID,
                    RunnerTable.COLUMN_NAME };
            CursorLoader cursorLoader = new CursorLoader(getActivity(),
                    FanContentProvider.CONTENT_URI, projection, null, null,
                    null);


            return cursorLoader;   //HERE IS THE PROBLEM
        }
        return null;
    }
Run Code Online (Sandbox Code Playgroud)

类型不匹配无法从CursorLoader转换为Loader.

我相信可以使它合作

public class MainFragment extends ListFragment implements
        //LoaderManager.LoaderCallbacks<Cursor>
        LoaderManager.LoaderCallbacks
Run Code Online (Sandbox Code Playgroud)

但不喜欢警告:

LoaderManager.LoaderCallbacks是一种原始类型.应参数化对泛型类型LoaderManager.LoaderCallbacks的引用

感谢您提供的任何帮助.

java android casting android-loadermanager

5
推荐指数
3
解决办法
5725
查看次数